<template>
  <div>
    测试题
    <zsxt-cmp-1 v-for="(item, i) in arr" :key="i" :item="item" />
    <hr />
    <zsxt-cmp-2 v-for="(item, i) in arr" :key="i" :idx="i" :item="item" />
  </div>
</template>

<script>
import ZsxtCmp1 from './zsxt_cmp1.vue'
import ZsxtCmp2 from './zsxt_cmp2.vue'
export default {
  name: 'Zsxt',
  components: {
    ZsxtCmp1,
    ZsxtCmp2,
  },
  data() {
    const _this = this
    return {
      arr: [
        {
          num1: _this.randomNum(),
          num2: _this.randomNum(),
          result: '',
        },
        {
          num1: _this.randomNum(),
          num2: _this.randomNum(),
          result: '',
        },
        {
          num1: _this.randomNum(),
          num2: _this.randomNum(),
          result: '',
        },
        {
          num1: _this.randomNum(),
          num2: _this.randomNum(),
          result: '',
        },
      ],
    }
  },
  methods: {
    randomNum(min = 1, max = 10) {
      min = Math.ceil(min)
      max = Math.floor(max)
      return Math.floor(Math.random() * (max - min + 1)) + min
    },
  },
}
</script>
